package com.example.szh.mvp.view;

import android.Manifest;
import android.os.Build;
import android.view.View;

import com.example.szh.R;
import com.example.szh.handler.TimerHandler;
import com.example.szh.mvp.contract.SplashContract;
import com.example.szh.mvp.di.DaggerSplashComponent;
import com.example.szh.mvp.di.SplashMoudes;
import com.example.szh.mvp.presenter.SplashPresenter;
import com.example.szh.nextwork.view.BaseActivity;
import com.example.szh.thread.TimerThread;

public class SplashActivity extends BaseActivity<SplashPresenter> implements SplashContract.ISplashIView , TimerHandler.TimerCallBack {

    @Override
    public View addStatusView() {
        return f(R.id.splash_linear);
    }

    @Override
    public void refresh() {
        new TimerThread(new TimerHandler(this)).start();
    }

    @Override
    public int bindLayout() {
        return R.layout.activity_splash;
    }

    @Override
    public void initView() {

    }

    @Override
    public void inject() {
        DaggerSplashComponent.builder().splashMoudes(new SplashMoudes(this)).build().injectSplash(this);
    }

    @Override
    public void initData() {
        if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){
            requestPermissions(new String[]{
                    Manifest.permission.CAMERA,
                    Manifest.permission.WRITE_EXTERNAL_STORAGE,
                    Manifest.permission.READ_EXTERNAL_STORAGE,
                    Manifest.permission.VIBRATE,
                    Manifest.permission.WAKE_LOCK,
                    Manifest.permission.READ_PHONE_STATE,
            },105);
        }
        p.requuestToken();
    }

    @Override
    public void callBack() {
        startPage(FragmentActivity.class);
        finish();
    }
}